package com.fr.cell.editor;

import com.fr.cell.event.FloatEditorEvent;
import com.fr.cell.event.FloatEditorListener;
import java.awt.event.KeyEvent;
import javax.swing.event.EventListenerList;

public abstract class AbstractFloatEditor
  implements FloatEditor
{
  private EventListenerList listenerList = new EventListenerList();
  private transient FloatEditorEvent floatEditEvent = null;

  public boolean acceptKeyEventToStartFloatEditing(KeyEvent paramKeyEvent)
  {
    return true;
  }

  public boolean stopFloatEditing()
  {
    fireEditingStopped();
    return true;
  }

  public void cancelFloatEditing()
  {
    fireEditingCanceled();
  }

  public void addFloatEditorListener(FloatEditorListener paramFloatEditorListener)
  {
    this.listenerList.add(FloatEditorListener.class, paramFloatEditorListener);
  }

  public void removeFloatEditorListener(FloatEditorListener paramFloatEditorListener)
  {
    this.listenerList.remove(FloatEditorListener.class, paramFloatEditorListener);
  }

  protected void fireEditingStopped()
  {
    Object[] arrayOfObject = this.listenerList.getListenerList();
    for (int i = arrayOfObject.length - 2; i >= 0; i -= 2)
      if (arrayOfObject[i] == FloatEditorListener.class)
      {
        if (this.floatEditEvent == null)
          this.floatEditEvent = new FloatEditorEvent(this);
        ((FloatEditorListener)arrayOfObject[(i + 1)]).editingStopped(this.floatEditEvent);
      }
  }

  protected void fireEditingCanceled()
  {
    Object[] arrayOfObject = this.listenerList.getListenerList();
    for (int i = arrayOfObject.length - 2; i >= 0; i -= 2)
      if (arrayOfObject[i] == FloatEditorListener.class)
      {
        if (this.floatEditEvent == null)
          this.floatEditEvent = new FloatEditorEvent(this);
        ((FloatEditorListener)arrayOfObject[(i + 1)]).editingCanceled(this.floatEditEvent);
      }
  }
}